home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: Mike Mitchell <72724.2067@CompuServe.COM>
- Newsgroups: comp.lang.c,comp.lang.c.moderated
- Subject: 8 Queens prog help
- Date: 19 Apr 1996 09:28:29 -0500
- Organization: CompuServe, Inc. (1-800-689-0736)
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4l87ud$73u@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
-
- Hi All!
-
- Need some C help this week. I'm currently working on a program
- called "Eight Queens". Basically, I have to place 8 queen chess
- pieces on an 8x8 chess board without them checking one another.
- The instructer wants us to use a "backtracking algorithm" (i.e. a
- tree structure) to accomplish this. My thoughts thus far are to
- place my first queen randomly and mark that space with a 'Q'
- character and then mark off all the squares in its legal paths
- (all adjacent squares vertical, horizontal, and diagonal to the
- ends of the board) with an 'X' character. Board is initialized
- to Nulls.
-
- When the next queen piece is placed I will check to see if
- another queen is in one of its paths. If there isn't I will
- place the piece and mark off its paths otherwise I will return
- the square to NULL and move to the next NULL square.
-
- Am I approaching this the right way or should I be handling this
- another way? Can someone explain how a tree structure
- accomplishes this?
-
- We did a similar problem in class using the knight piece and its
- legal moves. Well, needless to say the number of legal moves a
- queen can make, make this problem a little more difficult.
-